home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample PMSAM / PMSAM Framework / Common / CRString.cp < prev    next >
Encoding:
Text File  |  1995-07-28  |  14.3 KB  |  762 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CRString.cp
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Tim Harnett
  7.  
  8.     Copyright:    © 1992 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <4>     2/21/95    TMH        metrowerks changes
  13.          <3>     1/11/95    TMH        placated the compiler with a void* cast
  14.          <2>    10/13/94    TMH         added CRecordType assigment operator
  15.          <1>     9/20/94    TMH        Abandon RoadsideRest embrace Mercury
  16.         <10>     1/18/94    EMS        Added FormBackwardNameMethod
  17.          <9>    11/12/93    TMH        fix CString256::Strip
  18.          <8>     6/24/93    EMS        Fixed Strip
  19.          <7>     6/24/93    EMS        Fixed strip bug
  20.          <6>     6/22/93    EMS        Added Strip
  21.          <5>     1/14/93    TMH        a14 upgrades
  22.          <4>    10/29/92    TMH        RStringHandle constructors
  23.          <3>    10/29/92    TMH        handle nil pointers in CRecordType constructors
  24.          <2>     9/25/92    EMS        refined #include'ing of .h files and moved classes, globals etc.
  25.          <1>      9/8/92    TMH        The Great Project Restructuring of 1992
  26.          <4>     7/10/92    TMH        CRString* constructor for CAttributeType
  27.         <2+>     6/23/92    SMT        adding default constructor for CRString
  28.          <2>     6/23/92    TMH        fixed bugs in CRecordName constructors and assignment operator.
  29.                  5/28/92    TMH        New with A8 upgrades
  30.  
  31.     To Do:
  32. */
  33.  
  34. #ifndef     __CRString__
  35. #include     "CRString.h"
  36. #endif
  37.  
  38. /*
  39.  *    CRString
  40.  */
  41.  
  42. #pragma segment CRString
  43.  
  44. CRString::CRString()
  45. {
  46.     fCharSet = kDefaultCharSet;
  47.     fBodyLength = 0; 
  48. }
  49.  
  50. CRString::CRString(short charSet)
  51. {
  52.     fCharSet = charSet;
  53.     fBodyLength = 0; 
  54. }
  55.  
  56. //----------------------------------------------------------------------------------------------------
  57. void CRString::Strip( char theChar, Boolean /*stripAll*/, Boolean stripLeading, Boolean stripTrailing )
  58. {
  59.     //    We don't do strip All  yet
  60.  
  61.     short    sLen = fBodyLength;
  62.     char*    sPtr = (char*) fBody+(sLen-1);    // point to last char in string
  63.     
  64.     // Strip trailing blanks
  65.     while( stripTrailing && (sLen>0)  && (*sPtr==theChar) ) {
  66.         sPtr--;
  67.         sLen--;
  68.     }
  69.  
  70.  
  71.     sPtr = (char*)fBody;
  72.     
  73.     // Strip Leading Spaces
  74.     while( stripLeading && (sLen>0)  && (*sPtr==theChar) ) {
  75.         sPtr++;
  76.         sLen--;
  77.     }
  78.  
  79.  
  80.     if( (sLen != fBodyLength) &&  (sPtr != (char*)fBody) )
  81.         memcpy(fBody,sPtr,sLen);
  82.  
  83.  
  84.     fBodyLength = sLen;
  85.  
  86.     
  87. }
  88.  
  89.  
  90.  
  91. /*
  92.  *    CRString16
  93.  */
  94.  
  95.  
  96. CRString16::CRString16(const char* str,short charSet)
  97. {
  98.     
  99.     fBodyLength = str == 0  ? 0 : strlen(str);
  100.     
  101.     fCharSet = charSet;
  102.     
  103.     if( fBodyLength > kRString16BodySize )
  104.         fBodyLength = kRString16BodySize;
  105.         
  106.     memcpy(fBody,str,fBodyLength);
  107. }
  108.  
  109. CRString16::CRString16(const RString* rstr)
  110. {
  111.     if( rstr == 0 ) {
  112.         fCharSet = 0;
  113.         fBodyLength = 0;
  114.         
  115.     } else {
  116.  
  117.         fCharSet = rstr->charSet;
  118.         
  119.         fBodyLength = rstr->dataLength;
  120.         if( fBodyLength > kRString16BodySize )
  121.             fBodyLength = kRString16BodySize;
  122.             
  123.         memcpy(fBody,rstr->body,fBodyLength);
  124.     }
  125. }
  126.  
  127. CRString16::CRString16(const RStringHandle rstr)
  128. {
  129.     if( rstr == 0 ) {
  130.         fCharSet = 0;
  131.         fBodyLength = 0;
  132.         
  133.     } else {
  134.  
  135.         fCharSet = (*rstr)->charSet;
  136.         
  137.         fBodyLength = (*rstr)->dataLength;
  138.         if( fBodyLength > kRString16BodySize )
  139.             fBodyLength = kRString16BodySize;
  140.             
  141.         memcpy(fBody,(*rstr)->body,fBodyLength);
  142.     }
  143. }
  144.  
  145. CRString16::CRString16(const CStr255& cstr255,short charSet)
  146. {
  147.     fBodyLength = cstr255.Length();
  148.     fCharSet = charSet;
  149.     
  150.     if( fBodyLength > kRString16BodySize )
  151.         fBodyLength = kRString16BodySize;
  152.     
  153.     memcpy(fBody,&cstr255.fStr[1],fBodyLength);
  154.  
  155. }
  156.  
  157. //-------------------------
  158. //            C R S t r i n g 3 2
  159. //----------------------------
  160.  
  161.  
  162.  
  163. CRString32::CRString32(const char* str,short charSet)
  164. {
  165.     
  166.     fBodyLength = str == 0  ? 0 : strlen(str);
  167.     
  168.     fCharSet = charSet;
  169.     
  170.     if( fBodyLength > kRString32BodySize )
  171.         fBodyLength = kRString32BodySize;
  172.         
  173.     memcpy(fBody,str,fBodyLength);
  174. }
  175.  
  176. CRString32::CRString32(const RString* rstr)
  177. {
  178.     if( rstr == 0 ) {
  179.         fCharSet = 0;
  180.         fBodyLength = 0;
  181.         
  182.     } else {
  183.  
  184.         fCharSet = rstr->charSet;
  185.         
  186.         fBodyLength = rstr->dataLength;
  187.         if( fBodyLength > kRString32BodySize )
  188.             fBodyLength = kRString32BodySize;
  189.             
  190.         memcpy(fBody,rstr->body,fBodyLength);
  191.     }
  192. }
  193.  
  194. CRString32::CRString32(const RStringHandle rstr)
  195. {
  196.     if( rstr == 0 ) {
  197.         fCharSet = 0;
  198.         fBodyLength = 0;
  199.         
  200.     } else {
  201.  
  202.         fCharSet = (*rstr)->charSet;
  203.         
  204.         fBodyLength = (*rstr)->dataLength;
  205.         if( fBodyLength > kRString32BodySize )
  206.             fBodyLength = kRString32BodySize;
  207.             
  208.         memcpy(fBody,(*rstr)->body,fBodyLength);
  209.     }
  210. }
  211.  
  212. CRString32::CRString32(const CStr255& cstr255,short charSet)
  213. {
  214.     fBodyLength = cstr255.Length();
  215.     fCharSet = charSet;
  216.     
  217.     if( fBodyLength > kRString32BodySize )
  218.         fBodyLength = kRString32BodySize;
  219.     
  220.     memcpy(fBody,&cstr255.fStr[1],fBodyLength);
  221.  
  222. }
  223.  
  224.  
  225. /*
  226.  *    CRString256
  227.  */
  228.  
  229.  
  230. CRString256::CRString256(const char* str,short charSet)
  231. {
  232.     
  233.     fBodyLength = str == 0  ? 0 : strlen(str);
  234.     
  235.     fCharSet = charSet;
  236.     
  237.     if( fBodyLength > kRString256BodySize )
  238.         fBodyLength = kRString256BodySize;
  239.         
  240.     memcpy(fBody,str,fBodyLength);
  241. }
  242.  
  243. CRString256::CRString256(const RString* rstr)
  244. {
  245.     if( rstr == 0 ) {
  246.         fCharSet = 0;
  247.         fBodyLength = 0;
  248.         
  249.     } else {
  250.  
  251.         fCharSet = rstr->charSet;
  252.         
  253.         fBodyLength = rstr->dataLength;
  254.         if( fBodyLength > kRString256BodySize )
  255.             fBodyLength = kRString256BodySize;
  256.             
  257.         memcpy(fBody,rstr->body,fBodyLength);
  258.     }
  259. }
  260. CRString256::CRString256(const RStringHandle rstr)
  261. {
  262.     if( rstr == 0 ) {
  263.         fCharSet = 0;
  264.         fBodyLength = 0;
  265.         
  266.     } else {
  267.  
  268.         fCharSet = (*rstr)->charSet;
  269.         
  270.         fBodyLength = (*rstr)->dataLength;
  271.         if( fBodyLength > kRString256BodySize )
  272.             fBodyLength = kRString256BodySize;
  273.             
  274.         memcpy(fBody,(*rstr)->body,fBodyLength);
  275.     }
  276. }
  277.  
  278. CRString256::CRString256(const CStr255& cstr255,short charSet)
  279. {
  280.     fBodyLength = cstr255.Length();
  281.     fCharSet = charSet;
  282.     
  283.     if( fBodyLength > kRString256BodySize )
  284.         fBodyLength = kRString256BodySize;
  285.     
  286.     memcpy(fBody,&cstr255.fStr[1],fBodyLength);
  287.  
  288. }
  289.  
  290. /*
  291.  *    CRecordName
  292.  */
  293.  
  294. CRecordName::CRecordName() : CRString() { fCharSet = kDefaultCharSet; }
  295. CRecordName::CRecordName(const char* str,short charSet)
  296. {
  297.     
  298.     fBodyLength = str == 0  ? 0 : strlen(str);
  299.     
  300.     fCharSet = charSet;
  301.     
  302.     if( fBodyLength > kRecordNameBodySize )
  303.         fBodyLength = kRecordNameBodySize;
  304.         
  305.     memcpy(fBody,str,fBodyLength);
  306. }
  307.  
  308.  
  309. CRecordName::CRecordName(const RString* rstr)
  310. {
  311.     if( rstr == 0 ) {
  312.         fCharSet = 0;
  313.         fBodyLength = 0;
  314.         
  315.     } else {
  316.     
  317.         fBodyLength = rstr->dataLength;
  318.     
  319.         if( fBodyLength > kRecordNameBodySize )
  320.             fBodyLength = kRecordNameBodySize;
  321.         
  322.         fCharSet = rstr->charSet;
  323.         BlockMove((Ptr)rstr->body,(Ptr) fBody,fBodyLength);
  324.         
  325.     }
  326.  
  327. }
  328. CRecordName::CRecordName(const RStringHandle rstr)
  329. {
  330.     if( rstr == 0 ) {
  331.         fCharSet = 0;
  332.         fBodyLength = 0;
  333.         
  334.     } else {
  335.     
  336.         fBodyLength = (*rstr)->dataLength;
  337.     
  338.         if( fBodyLength > kRecordNameBodySize )
  339.             fBodyLength = kRecordNameBodySize;
  340.         
  341.         fCharSet = (*rstr)->charSet;
  342.         BlockMove((Ptr)(*rstr)->body,(Ptr) fBody,fBodyLength);
  343.         
  344.     }
  345.  
  346. }
  347.  
  348.  
  349. CRecordName::CRecordName(const CRString* crstr)
  350. {    
  351.     if( crstr == 0 ) {
  352.         fCharSet = 0;
  353.         fBodyLength = 0;
  354.         
  355.     } else {
  356.     
  357.         fBodyLength = crstr->fBodyLength;
  358.     
  359.         if( fBodyLength > kRecordNameBodySize )
  360.             fBodyLength = kRecordNameBodySize;
  361.         
  362.         fCharSet = crstr->fCharSet;
  363.         BlockMove((Ptr)crstr->fBody,(Ptr) fBody,fBodyLength);
  364.         
  365.     }
  366.  
  367. }
  368.  
  369. CRecordName::CRecordName(CRString16& rstr16) 
  370. {
  371.     memcpy(this,rstr16,rstr16.Length());
  372.     fCharSet = kDefaultCharSet;
  373. }
  374.  
  375. CRecordName::CRecordName(const CStr255& cstr255,short charSet)
  376. {
  377.     fBodyLength = cstr255.Length();
  378.     fCharSet = charSet;
  379.     
  380.     if( fBodyLength > kRecordNameBodySize )
  381.         fBodyLength = kRecordNameBodySize;
  382.     
  383.     memcpy(fBody,&cstr255.fStr[1],fBodyLength);
  384.  
  385. }
  386.  
  387. CRecordName& CRecordName::operator =(const RString* rstr) 
  388. {
  389.     if( rstr == 0 ) {
  390.         fCharSet = 0;
  391.         fBodyLength = 0;
  392.         
  393.     } else {
  394.     
  395.         fBodyLength = rstr->dataLength;
  396.     
  397.         if( fBodyLength > kRecordNameBodySize )
  398.             fBodyLength = kRecordNameBodySize;
  399.         
  400.         fCharSet = rstr->charSet;
  401.         BlockMove((Ptr)rstr->body,(Ptr) fBody,fBodyLength);
  402.         
  403.     }
  404.  
  405.     return *this;
  406.     
  407. };
  408.  
  409.  
  410.  
  411. //--------------------------------------------------------------------------------------
  412. Boolean        CRecordName::FormBackwardString( CRecordName& out, Boolean failMultipleBreaks )
  413. {
  414.     short splitChar = 32;
  415.     short split = this->fBodyLength;  
  416.     Boolean formable = false;
  417.  
  418.     if ( this->CharSet() == smRoman ) {
  419.     
  420.         //--    strip off trailing spaces.
  421.         while ( ( this->fBody[ split ] == 32 ) && split) split--;
  422.         
  423.         //--    find first space
  424.         while ( ( this->fBody[ split ]  != 32) && split ) split--;
  425.         
  426.         //--    If the orig string has more than one split then set split location to zero thereby blowing out.
  427.         if ( failMultipleBreaks ) {
  428.             short tempSpot = split;
  429.             while ( ( this->fBody[ tempSpot ]  != 32) && tempSpot ) tempSpot--;
  430.             if ( tempSpot > 0 )
  431.                 split = 0;
  432.         }
  433.     
  434.         if ( ( this->fBody[ split ] == 32 ) && split ) {    //build the alias name
  435.             formable = true;
  436.             
  437.             short lengthAfterSpace = this->fBodyLength - split - 1;
  438.             short lengthBeforeSpace = split;
  439.             
  440.             BlockMove(&this->fBody[ split + 1 ], &out.fBody[0], lengthAfterSpace);
  441.             
  442.             out.fBody[lengthAfterSpace] = ',';
  443.             
  444.             if ( this->fBodyLength < 63 ) {
  445.                 out.fBody[lengthAfterSpace + 1] = 32;
  446.                 BlockMove(&this->fBody[0], &out.fBody[lengthAfterSpace+2], lengthBeforeSpace );
  447.                 out.fBodyLength = this->fBodyLength + 1;
  448.             } else {
  449.                 BlockMove(&this->fBody[0], &out.fBody[lengthAfterSpace+1], lengthBeforeSpace );
  450.                 out.fBodyLength = this->fBodyLength;
  451.             }
  452.                         
  453.         } else {                                    //alias name is same as inputName
  454.         
  455.             BlockMove(&this->fBody[0], &out.fBody[0], this->fBodyLength);
  456.             out.fBodyLength = this->fBodyLength;
  457.         }
  458.         out.fCharSet = this->fCharSet;
  459.     }
  460.     
  461.     return formable;
  462. };
  463.  
  464.  
  465.  
  466.  
  467.  
  468. /*
  469.  *    CDirectoryName
  470.  */
  471.  
  472.  
  473. CDirectoryName::CDirectoryName(const char* str,short charSet)
  474. {
  475.     
  476.     fBodyLength = str == 0  ? 0 : strlen(str);
  477.     
  478.     fCharSet = charSet;
  479.     
  480.     if( fBodyLength > kDirectoryNameBodySize )
  481.         fBodyLength = kDirectoryNameBodySize;
  482.         
  483.     memcpy(fBody,str,fBodyLength);
  484. }
  485.  
  486. CDirectoryName::CDirectoryName(const RString* rstr)
  487. {
  488.     fCharSet = rstr->charSet;
  489.     
  490.     fBodyLength = rstr->dataLength;
  491.     if( fBodyLength > kDirectoryNameBodySize )
  492.         fBodyLength = kDirectoryNameBodySize;
  493.         
  494.     memcpy(fBody,rstr->body,fBodyLength);
  495. }
  496.  
  497. CDirectoryName::CDirectoryName(const CStr255& cstr255,short charSet)
  498. {
  499.     fBodyLength = cstr255.Length();
  500.     fCharSet = charSet;
  501.     
  502.     if( fBodyLength > kDirectoryNameBodySize )
  503.         fBodyLength = kDirectoryNameBodySize;
  504.     
  505.     memcpy(fBody,&cstr255.fStr[1],fBodyLength);
  506.  
  507. }
  508.  
  509. /*
  510.  *    CNetworkName
  511.  */
  512.  
  513.  
  514. CNetworkName::CNetworkName(const char* str,short charSet)
  515. {
  516.     
  517.     fBodyLength = str == 0  ? 0 : strlen(str);
  518.     
  519.     fCharSet = charSet;
  520.     
  521.     if( fBodyLength > kNetworkNameBodySize )
  522.         fBodyLength = kNetworkNameBodySize;
  523.         
  524.     memcpy(fBody,str,fBodyLength);
  525. }
  526.  
  527. CNetworkName::CNetworkName(const RString* rstr)
  528. {
  529.     fCharSet = rstr->charSet;
  530.     
  531.     fBodyLength = rstr->dataLength;
  532.     if( fBodyLength > kNetworkNameBodySize )
  533.         fBodyLength = kNetworkNameBodySize;
  534.         
  535.     memcpy(fBody,rstr->body,fBodyLength);
  536. }
  537.  
  538. CNetworkName::CNetworkName(const CRString* crstr)
  539. {
  540.     fBodyLength = crstr->BodyLength();
  541.     
  542.     if( fBodyLength > kNetworkNameBodySize )
  543.         fBodyLength = kNetworkNameBodySize;
  544.     
  545.     memcpy(this,crstr,sizeof(ProtoRString)+fBodyLength);
  546. }
  547.  
  548. CNetworkName::CNetworkName(const CStr255& cstr255,short charSet)
  549. {
  550.     fBodyLength = cstr255.Length();
  551.     fCharSet = charSet;
  552.     
  553.     if( fBodyLength > kNetworkNameBodySize )
  554.         fBodyLength = kNetworkNameBodySize;
  555.     
  556.     memcpy(fBody,&cstr255.fStr[1],fBodyLength);
  557.  
  558. }
  559.  
  560.  
  561. /*
  562.  *    CRecordType
  563.  */
  564.  
  565.  
  566. CRecordType::CRecordType(const char* str,short charSet)
  567. {
  568.     
  569.     fBodyLength = str == 0  ? 0 : strlen(str);
  570.     
  571.     fCharSet = charSet;
  572.     
  573.     if( fBodyLength > kRecordTypeBodySize )
  574.         fBodyLength = kRecordTypeBodySize;
  575.         
  576.     memcpy(fBody,str,fBodyLength);
  577. }
  578.  
  579. CRecordType::CRecordType(const RString* rstr)
  580. {
  581.     if( rstr == 0 ) {
  582.     
  583.         fCharSet = kDefaultCharSet;
  584.         fBodyLength = 0;
  585.         
  586.     }  else {
  587.     
  588.         fCharSet = rstr->charSet;
  589.         
  590.         fBodyLength = rstr->dataLength;
  591.         if( fBodyLength > kRecordTypeBodySize )
  592.             fBodyLength = kRecordTypeBodySize;
  593.             
  594.         memcpy(fBody,rstr->body,fBodyLength);
  595.     }
  596. }
  597. CRecordType::CRecordType(const RStringHandle rstr)
  598. {
  599.     if( rstr == 0 ) {
  600.     
  601.         fCharSet = kDefaultCharSet;
  602.         fBodyLength = 0;
  603.         
  604.     }  else {
  605.     
  606.         fCharSet = (*rstr)->charSet;
  607.         
  608.         fBodyLength = (*rstr)->dataLength;
  609.         if( fBodyLength > kRecordTypeBodySize )
  610.             fBodyLength = kRecordTypeBodySize;
  611.             
  612.         memcpy(fBody,(*rstr)->body,fBodyLength);
  613.     }
  614. }
  615.  
  616. CRecordType::CRecordType(const CRString* crstr)
  617. {
  618.     if( crstr == 0 ) {
  619.     
  620.         fCharSet = kDefaultCharSet;
  621.         fBodyLength = 0;
  622.         
  623.     }  else {
  624.  
  625.         fBodyLength = crstr->BodyLength();
  626.         
  627.         if( fBodyLength > kRecordTypeBodySize )
  628.             fBodyLength = kRecordTypeBodySize;
  629.         
  630.         memcpy(this,crstr,sizeof(ProtoRString)+fBodyLength);
  631.     }
  632.     
  633. }
  634.  
  635. CRecordType::CRecordType(const CStr255& cstr255,short charSet)
  636. {
  637.     fBodyLength = cstr255.Length();
  638.     fCharSet = charSet;
  639.     
  640.     if( fBodyLength > kRecordTypeBodySize )
  641.         fBodyLength = kRecordTypeBodySize;
  642.     
  643.     memcpy(fBody,&cstr255.fStr[1],fBodyLength);
  644.  
  645. }
  646.  
  647. CRecordType& CRecordType::operator =(const RString* rstr) 
  648. {
  649.     if( rstr == 0 ) {
  650.         fCharSet = 0;
  651.         fBodyLength = 0;
  652.         
  653.     } else {
  654.     
  655.         fBodyLength = rstr->dataLength;
  656.     
  657.         if( fBodyLength > kRecordTypeBodySize )
  658.             fBodyLength = kRecordTypeBodySize;
  659.         
  660.         fCharSet = rstr->charSet;
  661.         BlockMove((Ptr)rstr->body,(Ptr) fBody,fBodyLength);
  662.         
  663.     }
  664.  
  665.     return *this;
  666.     
  667. };
  668.  
  669.  
  670. /*
  671.  *    CAttributeType
  672.  */
  673.  
  674.  
  675. CAttributeType::CAttributeType(const char* str,short charSet)
  676. {
  677.     
  678.     fBodyLength = str == 0  ? 0 : strlen(str);
  679.     
  680.     fCharSet = charSet;
  681.     
  682.     if( fBodyLength > kAttributeTypeBodySize )
  683.         fBodyLength = kAttributeTypeBodySize;
  684.         
  685.     memcpy(fBody,str,fBodyLength);
  686. }
  687.  
  688. CAttributeType::CAttributeType(const RString* rstr)
  689. {
  690.  
  691.     if( rstr == 0 ) {
  692.         fCharSet = 0;
  693.         fBodyLength = 0;
  694.         
  695.     } else {
  696.     
  697.         fBodyLength = rstr->dataLength;
  698.     
  699.         if( fBodyLength > kAttributeTypeBodySize )
  700.             fBodyLength = kAttributeTypeBodySize;
  701.         
  702.         fCharSet = rstr->charSet;
  703.         BlockMove((Ptr)rstr->body,(Ptr) fBody,fBodyLength);
  704.         
  705.     }
  706.  
  707. }
  708. CAttributeType::CAttributeType(const RStringHandle rstr)
  709. {
  710.  
  711.     if( rstr == 0 ) {
  712.         fCharSet = 0;
  713.         fBodyLength = 0;
  714.         
  715.     } else {
  716.     
  717.         fBodyLength = (*rstr)->dataLength;
  718.     
  719.         if( fBodyLength > kAttributeTypeBodySize )
  720.             fBodyLength = kAttributeTypeBodySize;
  721.         
  722.         fCharSet = (*rstr)->charSet;
  723.         BlockMove((Ptr)(*rstr)->body,(Ptr) fBody,fBodyLength);
  724.         
  725.     }
  726.  
  727. }
  728.  
  729.  
  730. CAttributeType::CAttributeType(const CRString* crstr)
  731. {    
  732.     if( crstr == 0 ) {
  733.         fCharSet = 0;
  734.         fBodyLength = 0;
  735.         
  736.     } else {
  737.     
  738.         fBodyLength = crstr->fBodyLength;
  739.     
  740.         if( fBodyLength > kAttributeTypeBodySize )
  741.             fBodyLength = kAttributeTypeBodySize;
  742.         
  743.         fCharSet = crstr->fCharSet;
  744.         BlockMove((Ptr)crstr->fBody,(Ptr) fBody,fBodyLength);
  745.         
  746.     }
  747.  
  748. }
  749.  
  750.  
  751. CAttributeType::CAttributeType(const CStr255& cstr255,short charSet)
  752. {
  753.     fBodyLength = cstr255.Length();
  754.     fCharSet = charSet;
  755.     
  756.     if( fBodyLength > kAttributeTypeBodySize )
  757.         fBodyLength = kAttributeTypeBodySize;
  758.     
  759.     memcpy(fBody,&cstr255.fStr[1],fBodyLength);
  760.  
  761. }
  762.